package com.xtt.dynamic.datasource.aspect;

import com.xtt.dynamic.datasource.annotation.WR;
import com.xtt.dynamic.datasource.config.DynamicDataSource;
import com.xtt.dynamic.datasource.entity.Operation;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class DynamicDataSourceAspect {

    //前置通知
    @Before("within(com.xtt.dynamic.datasource.service.impl.*) && @annotation(wr)")
    public void before(JoinPoint joinPoint, WR wr){
        Operation name = wr.value();
        DynamicDataSource.name.set(name);
        System.out.println(name);
    }

    //环绕通知
}
